import website from '@/config/website';
import { getToken } from '@/util/auth'
import toolUtil from '@/util/toolUtil';
import {setStore, getStore} from '@/util/store'

export function reqCommonMsg(reqParams) {
  var reqCommonMsg = { 
    'head': {
      'chainnelId': 'PC', 
      'transCode': '', //交易码
      'transSeqNo': '',  //交易编号
      'tenantId':localStorage.getItem('tenantId') || 'DOOL1001', //租户号
      'tenantName':'', //租户名称
      'projectId': getStore({name: (getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).userId : '')+'projectInfo'})? getStore({name: (getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).userId : '')+'projectInfo'}).id : '',
      'projectNo': getStore({name: (getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).userId : '')+'projectInfo'})? getStore({name: (getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).userId : '')+'projectInfo'}).projectNo: '',
      'projectName': getStore({name: (getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).userId : '')+'projectInfo'})? getStore({name: (getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).userId : '')+'projectInfo'}).projectName: '',
      'realName': getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).realName : '', //用户名
      'userName': getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).userName : '',  //用户登录名
      'userId': getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).userId : '', //用户id
      'headImgUrl': getStore({name: 'userInfo'})? getStore({name: 'userInfo'}).headImgUrl : '', //头像地址
      'transTime': toolUtil.formatTimeYYMMDDhhmm(new Date()),
      'sign': '', //md5签名
      'dataSign': '', //数据签名
      'token': '', //getToken(),
      'refreshToken': ''
    },
    'body': {
      'singleBody': reqParams.singleBody || {}, // 单条记录 放这里  {}
      'listBody': reqParams.listBody || [], // 多条记录放这里 [{}]
      'extBody': reqParams.extBody || {}, // 扩展记录放这里 {}，主要用于动态表单传值
      'flowArea': reqParams.flowArea || {}, //流程处理区
      'sqlCondition': reqParams.sqlCondition || [], //自定义查询条件[]
      'sqlOrCondition': reqParams.sqlOrCondition || [], //自定义查询条件[]
      'orderRule': reqParams.orderRule || [],
      'currentPage': reqParams.currentPage,
      'pageSize': reqParams.pageSize || website.pageSize,
      'total': reqParams.total
    }
  };
  return reqCommonMsg;
}

/**  
 *    sqlCondition
 *    sqlOrCondition: [{
          column: 'demandNo',
          type: '=',
          value: '1'
        },{
          column: 'demandNo',
          type: '=',
          value: '2'
        }],
 */